<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${package}mapper.${pojo_name_mapper}">
    <resultMap type="${package}pojo.${pojo_name}" id="BaseResultMap">
        <#if COLUMNS?exists>
            <#list COLUMNS as model>
                <#if model.isPK == "true">
                    <id column="${model.columnName}" jdbcType="${model.columnType}" property="${model.javaName}" />
                <#else>
                    <result column="${model.columnName}" jdbcType="${model.columnType}" property="${model.javaName}"    />
                </#if>
            </#list>
        </#if>
    </resultMap>

    <sql id="Base_Column_List">
        <#list COLUMNS as model>
            <#if model_has_next>
                ${model.columnName},
            <#else>
                ${model.columnName}
            </#if>
        </#list>
    </sql>



    <select id="pageList"  resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM ${table_name}
        <#if COLUMNS?exists>
            WHERE 1= 1
            <#list COLUMNS as model>
                <#if model.javaType == "String">
                    <if test="null != exclude${model.javaName ? cap_first} and '' != exclude${model.javaName ? cap_first}">
                        and ${model.columnName} not in
                        <foreach item="exclude${model.javaName ? cap_first}By" collection="exclude${model.javaName ? cap_first}" separator="," open="(" close=")" index="">
                            ${r'#{'} exclude${model.javaName ? cap_first }By ${r'}'}
                        </foreach>
                    </if>
                </#if>
                <#if model.javaType == "String">
                    <if test="null != ${model.javaName } and '' != ${model.javaName}">
                        and ${model.columnName} in
                        <foreach item="${model.javaName }By" collection="${model.javaName}" separator="," open="(" close=")" index="">
                            ${r'#{'} ${model.javaName }By ${r'}'}
                        </foreach>
                    </if>
                </#if>
            </#list>
        </#if>
        <#if COLUMNS?exists>
        <#list COLUMNS as model>
        <#if model.isPK == "true">
            order by ${model.columnName} DESC
        </#if>
        </#list>
        </#if>
    </select>
</mapper>